package org.example.book.controller;


import org.example.book.adapter.Login3rdAdapter;
import org.example.book.pojo.BusinessLaunch;
import org.example.book.pojo.UserInfo;
import org.example.book.service.UserServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserServcie userServcie;

    @Autowired
    private Login3rdAdapter login3rdAdapter;

    @PostMapping("login")
    public String login(String account, String pwd) {
        return userServcie.login(account, pwd);
    }

    @PostMapping("register")
    public String register(@RequestBody UserInfo userInfo) {
        return userServcie.register(userInfo);
    }


    @GetMapping("/gitee")
    public String gitee(String code, String state) {
        return login3rdAdapter.loginByGitee(code, state);
    }


    @PostMapping("/business/launch")
    public List<BusinessLaunch> filterBusinessLaunch(@RequestParam("city") String city, @RequestParam("sex") String sex, @RequestParam("product") String product) {
        return userServcie.filterBusinessLaunch(city, sex, product);
    }
}
